﻿using System;
using System.Collections;
using Castle.Windsor;

namespace Sentient.Core
{
    public class IoC
    {
        private static IWindsorContainer _container = null;

        private static IWindsorContainer Container
        {
            get
            {
                if (_container == null)
                    throw new InvalidOperationException("Make sure you initialise the IoC class!");

                return _container;
            }
        }

        public static T Resolve<T>()
        {
            return Container.Resolve<T>();
        }

        public static T Resolve<T>(IDictionary args)
        {
            return Container.Resolve<T>(args);
        }

        public static void Initialise(IWindsorContainer container)
        {
            _container = container;
        }
    }
}
